function spaced_quiver(uv,space,cc,X,Y,linewidth)
% function spaced_quiver(uv,space,cc,X,Y,linewidth)
%   A wrapper function for quiver, allowing adjusting the spaces between
%   arrows. quiver produces dense arrow fields. For the sake of clarity,
%   you might want to subsample the vector field and display it sparsely.
%       
%    INPUTS:
%       uv - M*N*2 matrix of vector fields
%       space - space between arrows
%       optional:
%              X,Y - coordinates of the sparse points, see quiver for more
%              details
%               cc - color code of the arrows
%               linewidth - thickness of the arrows
%
if(nargin<3)
    cc='k';
end

if(nargin<6)
    linewidth=2;
end

dx=uv(:,:,1);
dy=uv(:,:,2);
dx=imresize(dx,1/space,'bilinear');
dy=imresize(dy,1/space,'bilinear');

if(nargin<4)
    quiver(dx,dy,'LineWidth',2,'Color',cc,'LineWidth',linewidth);
    axis equal off;
else
    quiver(X,Y,dx,dy,'LineWidth',2,'Color',cc,'LineWidth',linewidth);
    axis equal off;
end

end